Skip to content

fix: resolve Python 3.13 re.sub PatternError in bridge.py#383

Merged
asheshgoplani merged 1 commit intoasheshgoplani:mainfrom
yoshida-m-3:fix/python313-re-escape-in-bridge
Mar 26, 2026
Merged

fix: resolve Python 3.13 re.sub PatternError in bridge.py#383
asheshgoplani merged 1 commit intoasheshgoplani:mainfrom
yoshida-m-3:fix/python313-re-escape-in-bridge

Conversation

@yoshida-m-3
Copy link
Contributor

Summary

  • Fix re.PatternError: bad escape \u at position 2 when running the conductor bridge with Python 3.13+
  • Change raw string r"\1\u2022 " to regular string "\\1\u2022 " in _markdown_to_slack() replacement pattern

Problem

Python 3.13 promoted the DeprecationWarning for invalid escape sequences in re.sub() replacement strings to a hard re.PatternError. The raw string r"\1\u2022 " contains \u which is not a valid regex escape, causing the bridge to crash on every message:

re.PatternError: bad escape \u at position 2

This prevents the Slack bridge from sending any responses back to the channel.

Fix

Replace the raw string with a regular string so that:

  • \\1 is interpreted as the regex backreference \1
  • \u2022 is interpreted as the Unicode bullet character by Python

Test plan

  • Verified on Python 3.13.12 — bridge processes messages and sends responses to Slack without errors
  • The replacement still produces the correct bullet character () in Slack output

Python 3.13 raises `re.PatternError: bad escape \u` when using
`r"\1\u2022 "` as a replacement string in `re.sub()`. In Python 3.12
and earlier this was silently accepted, but 3.13 promoted the
DeprecationWarning to a hard error.

Change the raw string `r"\1\u2022 "` to a regular string `"\\1\u2022 "`
so that `\1` is a proper backreference and `\u2022` (bullet character)
is interpreted as a Unicode literal by Python, not by the regex engine.
@asheshgoplani asheshgoplani merged commit f015348 into asheshgoplani:main Mar 26, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants